import Immutable from 'immutable';
import { UPDATE_LAYER_FIELDS_REDUX } from './actionTypes';
import preloadedState from '../../preloadedState';

const defaultLayerInfo = preloadedState.get('layer');

function reducer(state = defaultLayerInfo, action) {
    const { type, payload } = action;

    let newState = state;

    switch (type) {
        case UPDATE_LAYER_FIELDS_REDUX:
            newState = newState.set('layerFields',Immutable.fromJS(payload));
            return newState;
        default:
            return state;
    }
}

export default reducer;
